package com.lc.soft.controller;

import com.lc.soft.entity.CommonParameter;
import com.lc.soft.entity.ParameterEntity;
import com.lc.soft.service.IParameterService;
import com.lc.soft.utils.ResponseResult;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("parameter")
@Log4j2
public class ParameterController {

    private IParameterService parameterService;

    @Autowired
    public ParameterController(IParameterService parameterService) {
        this.parameterService = parameterService;
    }

    @RequestMapping("create")
    public ResponseResult create(ParameterEntity parameterEntity) {
        Long start = new Date().getTime();
        ResponseResult responseResult = parameterService.create(parameterEntity);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }

    @RequestMapping("update")
    public ResponseResult updateMap(ParameterEntity parameterEntity) {
        Long start = new Date().getTime();
        ResponseResult responseResult = parameterService.update(parameterEntity);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }

    @RequestMapping("updateState")
    public ResponseResult updateState(ParameterEntity parameterEntity) {
        Long start = new Date().getTime();
        ResponseResult responseResult = parameterService.updateState(parameterEntity);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }

    @RequestMapping("findPagedParameterListByCondition")
    public ResponseResult findPagedParameterListByCondition(CommonParameter commonParameter) {
        Long start = new Date().getTime();
        ResponseResult responseResult = parameterService.findPagedParameterListByCondition(commonParameter);
        Long end = new Date().getTime();
        log.info("间隔时间：" + (end - start) + "ms");
        return responseResult;
    }
}
